package com.ruoyi.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ruoyi.common.enums.DelFlag;
import com.ruoyi.system.domain.HuoPinPriceHis;
import com.ruoyi.system.mapper.HuoPinPriceHisMapper;
import com.ruoyi.system.service.IHuoPinPriceHisService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 货品价格变化历史 服务实现类
 * </p>
 *
 * @author qubaofeng
 * @since 2025-02-24
 */
@Service
public class HuoPinPriceHisServiceImpl extends ServiceImpl<HuoPinPriceHisMapper, HuoPinPriceHis> implements IHuoPinPriceHisService {

    @Override
    public List<HuoPinPriceHis> selectHisList(Long huoPinId) {
        LambdaQueryWrapper<HuoPinPriceHis> param = new LambdaQueryWrapper<>();
        param.eq(HuoPinPriceHis::getDelFlag, DelFlag.NOMAL.getCode());
        param.eq(HuoPinPriceHis::getHuoPinId, huoPinId);

        param.orderByDesc(HuoPinPriceHis::getCreateTime);
        param.last("limit 20");

        return baseMapper.selectList(param);
    }
}
